﻿@using NetCoreCMS.Models;
@using NetCoreCMS.Common;
@{
    Layout = "~/Areas/admin/Views/Shared/_LayoutEdit.cshtml";
    ViewBag.Title = "编辑内容";
    Sysconfig sysConfig = ViewData["config"] as Sysconfig;
    List<SelectListItem> categoryList = ViewData["categoryList"] as List<SelectListItem>;
    Shop m = ViewData["model"] as Shop;
}
@section HeaderContent{
    <script src="~/editor/ueditor.config.js"></script>
    <script src="~/editor/ueditor.all.min.js"></script>
    <script src="~/editor/lang/zh-cn/zh-cn.js"></script>
    <script>
   var artId = Number(@ViewBag.Id);
   $(function () {
      //初始化表单验证
      $("#form1").initValidform();

      //初始化编辑器
      $(".editor").each(function (i) {
         var objId = $(this).attr("id");
         if (objId != "undefined") {
            var editor = UE.getEditor(objId, {
               serverUrl: '/upload_ajax/index',
               initialFrameWidth: '100%',
               initialFrameHeight: 350
            });
         }
      });
      $(".editor-mini").each(function (i) {
         var objId = $(this).attr("id");
         if (objId != "undefined") {
            var editorMini = UE.getEditor(objId, {
               serverUrl: '/upload_ajax/index',
               initialFrameWidth: '100%',
               initialFrameHeight: 250,
               toolbars: [[
                   'fullscreen', 'source', '|', 'undo', 'redo', '|',
                   'bold', 'italic', 'underline', 'strikethrough', 'removeformat', 'pasteplain', '|', 'forecolor', 'insertorderedlist', 'insertunorderedlist', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                'link', 'unlink', 'anchor', '|',
                'simpleupload', 'insertimage', 'scrawl', 'insertvideo'
               ]]
            });
         }
      });



      //初始化上传控件
      $(".upload-img").InitUploader({ filesize: "@sysConfig.imgsize", sendurl: "/upload_ajax/index", swf: "/scripts/webuploader/uploader.swf", filetypes: "@sysConfig.fileextension" });
      $(".upload-album").InitUploader({ btntext: "批量上传", multiple: true, water: true, thumbnail: true, filesize: "@sysConfig.imgsize", sendurl: "/upload_ajax/index", swf: "/scripts/webuploader/uploader.swf" });

      //设置封面图片的样式
      $(".photo-list ul li .img-box img").each(function () {
         if ($(this).attr("src") == $("#hidFocusPhoto").val()) {
            $(this).parent().addClass("selected");
         }
      });

        //经度
      $(".map-btn").click(function () {
         showMapDialog(this);
      });

   });

       
   //初始化map窗口
   function showMapDialog(obj) {
      var d = top.dialog({
         id: 'mapDialogId',
         padding: 0,
         title: "在线地图",
          url: '../dialog_map/index',
          width: 643,
          height: 553
      }).showModal();
      //将容器对象传进去
      d.data = obj;
   }

   //批量删除
   function submitDelete() {
      var channel_id = Number(@ViewBag.ChannelId);
      var $row = $("#ltable tr:gt(0)");
      var json = { channel_id: channel_id, id: artId, list: [] };
      $($row).each(function (i, item) {
         if ($(item).find("input:checkbox").prop("checked")) {
            var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
            var obj = { id: id };
            json.list.push(obj);
         }
      });
   }

   //ExePostBack回调函数
   function __doPostBack(objId) {
      if (objId == "btnDelete") {
         submitDelete();
      }
   }

    </script>
}
<form id="form1" method="post" action="SubmitSave?action=@ViewBag.Action&id=@ViewBag.Id">
    <!--导航栏-->
    <div class="location">
        <a href="../shop_list/index" class="back"><i class="iconfont icon-up"></i><span>返回列表页</span></a>
        <a href="../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <a href="../shop_list/index"><span>内容管理</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>编辑内容</span>
        <div class="clipboard">
            <span><label id="clipMess"></label></span>
            <a href="javascript:;" class="copy" onclick="copy();"><i class="iconfont icon-copy"></i><span>复制</span></a>
            <a href="javascript:;" class="paste disable" onclick="paste();"><i class="iconfont icon-log"></i><span>粘贴</span></a>
        </div>
    </div>
    <div class="line10"></div>
    <!--/导航栏-->
    <!--内容-->
    <div id="floatHead" class="content-tab-wrap">
        <div class="content-tab">
            <div class="content-tab-ul-wrap">
                <ul>
                    <li><a class="selected" href="javascript:;">基本信息</a></li>
                    <li><a href="javascript:;">详细描述</a></li>
                    <li><a href="javascript:;">SEO选项</a></li>
                </ul>
            </div>
        </div>
    </div>

    <!-- 基本信息 -->
    <div class="tab-content">
        <dl>
            <dt>所属类别</dt>
            <dd>
                <div class="rule-single-select">
                    @Html.DropDownList("ddlCategoryId", new SelectList(categoryList, "Value", "Text", m.category_id.ToString()), new { datatype = "*", sucmsg = " " })
                </div>
            </dd>
        </dl>
        <dl>
            <dt>是否锁定</dt>
            <dd>
                <div class="rule-single-checkbox">
                    @Html.CheckBox("cbLock", m.is_lock != 0, new { id = "cbLock" })
                </div>
                <span class="Validform_checktip">*锁定后商铺禁止收款提现</span>
            </dd>
        </dl>
        <dl>
            <dt>是否供货</dt>
            <dd>
                <div class="rule-single-checkbox">
                    @Html.CheckBox("cbSupply", m.is_supply != 0, new { id = "cbSupply" })
                </div>
                <span class="Validform_checktip">*锁定后商铺禁止收款提现</span>
            </dd>
        </dl>
        <dl>
            <dt>推荐类型</dt>
            <dd>
                <div class="rule-multi-checkbox">
                    <span>
                        @Html.CheckBox("cblItem_1", m.is_top == 1, new { id = "cblItem_1" })<label for="cblItem_1">置顶</label>
                        @Html.CheckBox("cblItem_2", m.is_red == 1, new { id = "cblItem_2" })<label for="cblItem_2">推荐</label>
                        @Html.CheckBox("cblItem_3", m.is_hot == 1, new { id = "cblItem_3" })<label for="cblItem_3">热门</label>
                        @Html.CheckBox("cblItem_4", m.is_slide == 1, new { id = "cblItem_4" })<label for="cblItem_4">幻灯片</label>
                    </span>
                </div>
            </dd>
        </dl>
        <dl>
            <dt>商铺名称</dt>
            <dd>
                @Html.TextBox("txtShopname", m.shopname, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*标题最多100个字符</span>
            </dd>
        </dl>
        <dl>
            <dt>店主</dt>
            <dd>
                @Html.TextBox("txtUsername", (string)ViewBag.username, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*店主用户名</span>
            </dd>
        </dl>
        <dl>
            <dt>手机电话</dt>
            <dd>
                @Html.TextBox("txtMobile", m.mobile, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*最多100个字符</span>
            </dd>
        </dl>
        <dl>
            <dt>地址</dt>
            <dd>
                @Html.TextBox("txtAddress", m.address, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*</span>
            </dd>
        </dl>
        <dl>
            <dt>经度</dt>
            <dd>
                @Html.TextBox("txtXPoint", m.longitude, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*</span>
            </dd>
        </dl>
        <dl>
            <dt>维度</dt>
            <dd>
                @Html.TextBox("txtYPoint", m.latitude, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })
                <span class="Validform_checktip">*标题最多100个字符</span>
            </dd>
        </dl>
        <!-- 经维 -->
        <dl id="div_spec__container">
            <dt>经维度</dt>
            <dd>
                <a class="icon-btn add map-btn"><span>设置地图</span></a>
            </dd>
        </dl>
        <!-- /经维-->
        <dl>
            <dt>封面图片</dt>
            <dd>
                @{
                    //不是相册图片就绑定
                    string filename = "";
                    if (m.img_url != null)
                        filename = m.img_url.Substring(m.img_url.LastIndexOf("/") + 1);
                }
                @Html.TextBox("txtImgUrl", !filename.StartsWith("thumb_") ? m.img_url : "", new { @class = "input normal upload-path" })
                <div class="upload-box upload-img"></div>
            </dd>
        </dl>
        <!-- 余额 -->
        <dl>
            <dt>余额</dt>
            <dd>
                @Html.TextBox("txtPoint", m.point, new { @class = "input small", datatype = @"/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/", sucmsg = " " }) 元
                <span class="Validform_checktip">余额</span>
            </dd>
        </dl>
        <!-- /余额 -->
        <!-- 提现折扣 -->
        <dl>
            <dt>提现折扣</dt>
            <dd>
                @Html.TextBox("txtZhekuo", m.zhekou, new { @class = "input small", datatype = @"/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/", sucmsg = " " })
                <span class="Validform_checktip">提现折扣</span>
            </dd>
        </dl>
        <!-- /提现折扣 -->
        <dl>
            <dt>排序数字</dt>
            <dd>
                @Html.TextBox("txtSortId", m.sort_id.ToString(), new { @class = "input small", datatype = "n", sucmsg = " " })
                <span class="Validform_checktip">*数字，越小越向前</span>
            </dd>
        </dl>
        <dl>
            <dt>发布时间</dt>
            <dd>
                @Html.TextBox("txtAddTime", m.add_time.ToString("yyyy-MM-dd HH:mm:ss"), new { @class = "input rule-date-input", onfocus = "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})", datatype = @"/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}\s{1}(\d{1,2}:){2}\d{1,2}$/", errormsg = "请选择正确的日期", sucmsg = " " })
                <span class="Validform_checktip">不选择默认当前发布时间</span>
            </dd>
        </dl>
        <dl ID="div_albums_container">
            <dt>图片相册</dt>
            <dd>
                <div class="upload-box upload-album"></div>
                <input type="hidden" name="hidFocusPhoto" id="hidFocusPhoto" value="@ViewBag.hidFocusPhoto" class="focus-photo" />
                <div class="photo-list">
                    <ul>
                        @if (m.albums != null)
                        {
                            foreach (Shop_albums item in m.albums)
                            {
                                <li>
                                    <input type="hidden" name="hid_photo_name" value="@item.id|@item.original_path|@item.thumb_path" />
                                    <input type="hidden" name="hid_photo_remark" value="@item.remark" />
                                    <div class="img-box" onclick="setFocusImg(this);">
                                        <img src="@item.thumb_path" bigsrc="@item.original_path" />
                                        <span class="remark">
                                            <i>@(item.remark == "" ? "暂无描述..." : item.remark)</i>
                                        </span>
                                    </div>
                                    <a href="javascript:;" onclick="setRemark(this);">描述</a>
                                    <a href="javascript:;" onclick="delImg(this);">删除</a>
                                </li>
                            }
                        }
                    </ul>
                </div>
            </dd>
        </dl>
    </div>
    <!-- /基本信息 -->
    <!-- 详细描述 -->
    <div class="tab-content" style="display:none">
        <dl>
            <dt>业务范围</dt>
            <dd>
                @Html.TextArea("txtYewu", m.yewu, new { @class = "input", datatype = "*0-255", sucmsg = " " })
                <span class="Validform_checktip">业务</span>
            </dd>
        </dl>
        <dl>
            <dt>内容摘要</dt>
            <dd>
                @Html.TextArea("txtZhaiyao", m.zhaiyao, new { @class = "input", datatype = "*0-255", sucmsg = " " })
                <span class="Validform_checktip">不填写则自动截取内容前255字符</span>
            </dd>
        </dl>
        <dl>
            <dt>商铺介绍</dt>
            <dd>
                @Html.TextArea("txtContent", m.remark, new { @class = "editor" })
            </dd>
        </dl>
    </div>
    <!-- /详细描述 -->
    <!-- SEO选项 -->
    <div class="tab-content" style="display:none">
        <dl>
            <dt>SEO标题</dt>
            <dd>
                @Html.TextBox("txtSeoTitle", m.seo_title, new { @class = "input normal", maxlength = "255", datatype = "*0-100", sucmsg = " " })
                <span class="Validform_checktip">255个字符以内</span>
            </dd>
        </dl>
        <dl>
            <dt>SEO关健字</dt>
            <dd>
                @Html.TextArea("txtSeoKeywords", m.seo_keywords, new { @class = "input normal", datatype = "*0-255", sucmsg = " " })
                <span class="Validform_checktip">以“,”逗号区分开，255个字符以内</span>
            </dd>
        </dl>
        <dl>
            <dt>SEO描述</dt>
            <dd>
                @Html.TextArea("txtSeoDescription", m.seo_description, new { @class = "input", datatype = "*0-255", sucmsg = " " })
                <span class="Validform_checktip">255个字符以内</span>
            </dd>
        </dl>
    </div>
    <!-- /SEO选项 -->
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <input type="submit" id="btnSubmit" class="btn" value="提交保存" />
            <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
        </div>
    </div>
    <!--/工具栏-->
</form>
